package com.yc.blog.controller;

import com.yc.blog.entity.Result;
import com.yc.blog.service.BizException;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * SpringMVC 异常拦截器
 */
@Component
@ControllerAdvice
public class ExceptionHandler {

    @org.springframework.web.bind.annotation.ExceptionHandler(BizException.class)
    @ResponseBody
    public Result handle(BizException be){
        return Result.failure(be.getMessage());
    }
}
